/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.dao.impl;

import com.ivanbiz.dao.PiutangDAO;
import com.ivanbiz.helper.HibernateUtil;
import com.ivanbiz.model.Piutang;
import java.util.List;
import org.hibernate.Session;

/**
 *
 * @author Administrator
 */
public class PiutangDAOImpl extends GenericDAOImpl implements PiutangDAO {

    @Override
    public List getByJatuhTempo(Object date) throws Exception {
        try {
            Session session = HibernateUtil.getSession();
            String query = "from com.ivanbiz.model.Piutang h "
                    + "where h.jatuhTempo <'" + date + "' "
                    + "and h.sisaHutang !=0";
            List list = session.createQuery(query).list();
            return list;
        } catch (Exception e) {
            HibernateUtil.rollbackTransaction();
            throw e;
        } finally {
            HibernateUtil.closeSession();
        }
    }

    @Override
    public List<Piutang> getByBelumLunas() throws Exception {
        try {
            Session session = HibernateUtil.getSession();
            String query = "from com.ivanbiz.model.Piutang h "
                    + "where h.sisaHutang !=0";
            List list = session.createQuery(query).list();
            return list;
        } catch (Exception e) {
            HibernateUtil.rollbackTransaction();
            throw e;
        } finally {
            HibernateUtil.closeSession();
        }
    }
}
